//
//  BaseTableViewController.swift
//  DSWeiBo
//
//  Created by Frank Wang on 7/6/16.
//  Copyright © 2016 Frank Wang. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorViewDelegate {
        /**
         loadView 方法是一加载就执行
         定义一个变量保存当前用户是否登录
         */
        
        var userLogin = true
        
        //定义属性保存为登录界面
        
        var visitorView : VisitorView?
        
        
        override func loadView() {
                
                userLogin ? super.loadView() : setVisitorView()
                
        }
        
        private func setVisitorView(){
                //初始化未登录的界面
                let customView = VisitorView()
                customView.delegate = self
                customView.backgroundColor = UIColor.whiteColor()
                view = customView
                visitorView = customView
                
                //处理为登录的按钮
                navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(BaseTableViewController.registerBtnClick))
                
                navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(BaseTableViewController.loginBtnClick))
                
//                navigationController?.navigationBar.tintColor = UIColor.orangeColor()
                
                //设置外观来改变文字的颜色，外观设置，全局有效
                
        }

        
        func loginBtnClick() {
                print(#function)
        }
        
        func registerBtnClick() {
                print(#function )
        }
}
